Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding helper methods for cluster share and unshare #2729

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ak-px
Copy link
Contributor

@ak-px ak-px commented Aug 12, 2024

What this PR does / why we need it:
Adding helper methods cluster share and unshare

  • ShareCluster
  • ShareClusterWithValidation
  • UnShareCluster
  • UnShareClusterWithValidation
  • ValidateShareCluster
  • ValidateShareClusterBackup
  • ValidateUnShareCluster

Which issue(s) this PR fixes (optional)
Closes #PB-7787
#PB-7788
#PB-7789

Special notes for your reviewer:
The methods are not tested, will fix any issue during testcase automation phase.

@ak-px ak-px requested a review from a team as a code owner August 12, 2024 06:07
@ak-px ak-px marked this pull request as draft August 12, 2024 06:07
@ak-px ak-px self-assigned this Aug 12, 2024
@ak-px ak-px added Px-Backup Lib ready-for-review PR is ready for review labels Aug 12, 2024
@ak-px ak-px force-pushed the ak/topic/cluster_share_master branch 2 times, most recently from 78f0e60 to 99964cd Compare August 12, 2024 06:15
@ak-px ak-px marked this pull request as ready for review August 12, 2024 07:31
@ak-px ak-px requested review from a team and sgajawada-px August 12, 2024 07:32
@ak-px ak-px assigned vsundarraj-px and ak-px and unassigned vsundarraj-px and ak-px Aug 12, 2024
@ak-px ak-px requested a review from vsundarraj-px August 12, 2024 08:48
@ak-px ak-px force-pushed the ak/topic/cluster_share_master branch from 99964cd to 0e81a54 Compare August 12, 2024 08:54
Copy link
Contributor

@vsundarraj-px vsundarraj-px left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation is verified with object values, but I would suggest validation should include creating Backup/backupSchedule and Restore objects. That is what the cluster share will ensure operation when shared.

}

// ShareClusterWithValidation shares a cluster with users and groups and optionally shares existing backups and validates the share.
func ShareClusterWithValidation(ctx context1.Context, clusterName string, clusterUid string, users []string, groups []string, shareClusterBackups bool) (*api.ShareClusterResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you re Use ShareCluster function and avoid duplicate code for Sharing the cluster.
10522 - 10540 is duplicate of function ShareCluster Please reuse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

// UnShareClusterWithValidation unshares a cluster with users and groups and validates the unshare.
func UnShareClusterWithValidation(ctx context1.Context, clusterName string, clusterUid string, users []string, groups []string) (*api.UnShareClusterResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, please avoid duplicate code and reuse UnshareCluster

Uid: clusterUid,
}

// Inspect cluster to retrieve collaborators
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are functional level validation and more specificly this seems to me like a unit test case. than system test. Its good to have but will add test run time.

I would suggest to validate access through Backup Operations such as
Create Backup by shared user on the cluster
Create backup by user part of the group to which the cluster is shared.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are part of the helper method validation. All other backup-related CRUD operations will be validated at the test case level. This serves as a basic validation for the system tests.

}

// Validate that the entire list matches
if !AreStringSlicesEqual(userIds, users) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will ensure that the fetched list from collaborators doesn't contain any extra entries.

return
}
log.Infof("Inspecting cluster [%s] with user [%s]", clusterName, user)
_, err = backupDriver.InspectCluster(nonAdminCtx, req)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer createBackup, createBackupSchedule and Create restore on this cluster is better validation .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All backup-related CRUD operations will be tested at the test case level

return
}

if backupObj.GetBackup().UserBackupshareAccess != api.BackupShare_Restorable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be changed to create Restore from backup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, This serves as a basic validation to ensure the backup object has Restore access after the cluster is shared. All other CRUD operations will be validated at the test case level.

Name: backupName,
}
log.Infof("Inspecting backup [%s] with user [%s]", backupName, user)
backupObj, err := backupDriver.InspectBackup(nonAdminCtx, backupInspectRequest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of inspect you should execute Restore from backup.

@ak-px ak-px force-pushed the ak/topic/cluster_share_master branch 2 times, most recently from 36914ba to f42f4ed Compare August 16, 2024 04:20
Copy link
Contributor

@sabrarhussaini sabrarhussaini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ak-px ak-px force-pushed the ak/topic/cluster_share_master branch from f42f4ed to 8c14afe Compare August 27, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants